package com.example.app.components.MyButton

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.dp
import com.example.app.components.MyIcon.MyIcon
import com.example.app.components.MyListItem.MyListItem
import com.example.app.components.MySpacer.MySpacer
import com.example.app.components.MyText.MyText

@Composable
fun MyBlockOutlineButton(
    enabled: Boolean = true,
    imageVector: ImageVector? = null
) {
    MyListItem(headlineContent = {
        MyOutlinedButton(enabled = enabled,
                         border = BorderStroke(
                             3.dp,
                             if (enabled) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.background
                         ),
                         colors = ButtonDefaults.outlinedButtonColors(
                             contentColor = MaterialTheme.colorScheme.primary,
                             containerColor = MaterialTheme.colorScheme.surface,
                         ),
                         modifier = Modifier.fillMaxWidth(),
                         onClick = { /*TODO*/ }) {
            Row(
                horizontalArrangement = Arrangement.Center,
                verticalAlignment = Alignment.CenterVertically
            ) {
                MyText(text = "保存")
                MySpacer(modifier = Modifier.width(6.dp))
                if (imageVector != null) {
                    MyIcon(
                        modifier = Modifier.size(24.dp),
                        imageVector = imageVector,
                        tint = if (enabled) MaterialTheme.colorScheme.primary else ButtonDefaults.outlinedButtonColors().disabledContentColor
                    )
                }
            }
        }
    })
}